import 'package:flutter/material.dart';

class FileList extends StatelessWidget {
  final List<String> files;
  final String selectedFile;
  final Function(String) onFileSelected;

  const FileList({
    super.key,
    required this.files,
    required this.selectedFile,
    required this.onFileSelected,
  });

  Color _getFileColor(String filename) {
    if (filename.contains('周报')) return Colors.blue;
    if (filename.contains('会议')) return Colors.green;
    if (filename.contains('TODO')) return Colors.red;
    if (filename.contains('日记')) return Colors.purple;
    if (filename.contains('计划')) return Colors.orange;
    return Colors.black;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.grey[100],
      child: ListView.builder(
        itemCount: files.length,
        itemBuilder: (context, index) {
          final file = files[index];
          return ListTile(
            title: Text(
              file,
              style: TextStyle(
                color: _getFileColor(file),
              ),
            ),
            selected: file == selectedFile,
            onTap: () => onFileSelected(file),
          );
        },
      ),
    );
  }
}